package com.yt.app.provider.dao.impl;

import com.yt.app.core.model.UserOrderDetail;
import com.yt.app.provider.dao.UserOrderDetailDao;
import com.yt.core.dao.GenericDaoImpl;
import org.apache.ibatis.session.RowBounds;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by liujunshi on 16-1-22.
 */
public class UserOrderDetailDaoImpl extends GenericDaoImpl<UserOrderDetail, Long> implements UserOrderDetailDao {
	public UserOrderDetailDaoImpl() {
		setNameSpace("com.yt.app.userorderdetail");
	}

	@Override
	public int decreaseLeftCount(Long userOrderDetailId) {
		return this.getSqlSession().update(this.getNameSpace() + ".decreaseLeftCount", userOrderDetailId);
	}
	@Override
	public List<UserOrderDetail> getValidDetailListByUid(Long uid, Long lastId, Integer limit){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		if(lastId != null && lastId > 0) {
			params.put("lastId", lastId);
		}
		return this.getSqlSession().selectList(this.getNameSpace() + ".getValidDetailListByUid", params, new RowBounds(0, limit));
	}
}
